package com.t4l.client.screens.login.main.chat;

import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.t4l.client.images.Images;

public class T4LChat extends Composite {

	private ScrollPanel scroller;

	public T4LChat() {
		VerticalPanel list = new VerticalPanel();
		list.setHeight("100%");
		list.setWidth("100%");

		for (int i = 0; i < 50; i++) {
			HorizontalPanel item = new HorizontalPanel();
			item.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
			item.add(new Image(Images.get().defaultContact()));
			Hyperlink anchor = new Hyperlink("Contacto " + i,"ctc" + i );
			item.add(anchor);
			list.add(item);

		}
		scroller = new ScrollPanel(list);
		initWidget(scroller);
		getElement().setId("t4l-chat-panel");
	}

	/**
	 * Create a widget to display in the header that includes an image and some
	 * text.
	 * 
	 * @param text
	 *            the header text
	 * @param image
	 *            the {@link ImageResource} to add next to the header
	 * @return the header widget
	 */
	private Widget createHeaderWidget(String text, ImageResource image) {
		// Add the image and text to a horizontal panel
		HorizontalPanel hPanel = new HorizontalPanel();
		hPanel.setHeight("100%");
		hPanel.setSpacing(0);
		hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		hPanel.add(new Image(image));
		HTML headerText = new HTML(text);
		hPanel.add(headerText);
		return new SimplePanel(hPanel);
	}
}
